package banmuoi.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import banmuoi.entity.OrderDetail;
import banmuoi.entity.Order;
import banmuoi.util.HibernateUtil;

@WebServlet("/crudOrderDetail.do")
public class OrderDetailAdmin extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String orderId = req.getParameter("orderid");
		
		Session session = HibernateUtil.openSession();
	
		//HIỆN DANH SÁCH
		if(orderId != null && orderId != ""){
			int idOrder = Integer.parseInt(orderId);
			Order entity = (Order) session.load(Order.class, idOrder);
			req.setAttribute("entity", entity);
		}else
		{
			req.getRequestDispatcher("admin/OrderAdmin.jsp").forward(req, resp);
			session.close();
			return;
		}
		
		req.getRequestDispatcher("admin/OrderDetailAdmin.jsp").forward(req, resp);			
		session.close();
	}
	
	
	
}
